import { NgModule } from '@angular/core';
import { PreloadAllModules, RouterModule, Routes } from '@angular/router';
import { LayoutBlankComponent } from '../layout/blank/blank.component';
// layout
import { LayoutPassportComponent } from '../layout/passport/passport.component';
import { LayoutTabsComponent } from '../layout/tabs/tabs.component';
import { ChatComponent } from './chat/chat.component';
import { ContactComponent } from './contact/contact.component';
import { MyComponent } from './my/my.component';
// single pages
import { CallbackComponent } from './passport/callback.component';

const routes: Routes = [
  { path: '', redirectTo: '/tab/chat', pathMatch: 'full' },
  { path: 'tab', 
    component: LayoutTabsComponent,
    children: [
      { path: 'chat', component: ChatComponent },
      { path: 'contact', component: ContactComponent },
      { path: 'my', component: MyComponent },
    ]
  },
  { path: 'chat', loadChildren: () => import('./chat/chat.module').then((m) => m.ChatModule) },
  { path: 'contact', loadChildren: () => import('./contact/contact.module').then((m) => m.ContactModule) },
  { path: 'my', loadChildren: () => import('./my/my.module').then((m) => m.MyModule) },
  // 空白布局
  {
      path: 'blank',
      component: LayoutBlankComponent,
      children: [
      ]
  },
  // passport
  {
    path: 'passport',
    component: LayoutPassportComponent,
    children: [
      { path: '', loadChildren: () => import('./passport/passport.module').then((m) => m.PassportModule) },
    ]
  },
  // 单页不包裹Layout
  { path: 'passport/callback/:type', component: CallbackComponent },
];

@NgModule({
  imports: [
    RouterModule.forRoot(routes, { preloadingStrategy: PreloadAllModules })
  ],
  exports: [RouterModule]
})
export class RouteRoutingModule { }
